package com.thinkit.bigdata.web.controller.bus;

import com.thinkit.bigdata.web.model.result.HtmlResult;
import com.thinkit.bigdata.web.service.perCenter.PerCenDetService;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/test-model-detail")
public class TestDetailController {

    private static Logger logger = Logger.getLogger(TestDetailController.class);

    @Resource
    private PerCenDetService perCenDetService;

    @RequestMapping(value = "/get-rule-list", method = RequestMethod.POST)
    public HtmlResult getRuleList(HttpServletRequest request) {
        String logTxt = "【获取模型测检规则方法】";
        logger.info(logTxt);
        String serialNumber = request.getParameter("serialNumber");//录音流水
        String workId = request.getParameter("workId");//质检任务Id
        logger.info(logTxt + "serialNumber = " + serialNumber);
        logger.info(logTxt + "workId = " + workId);
        try {
            return perCenDetService.getTestRulesBySerialNumber(serialNumber, workId);
        } catch (Exception e) {
            e.printStackTrace();
            return HtmlResult.failure(logTxt + "获取规则信息失败");
        }
    }
}
